package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.dubbo.api.mapper.BlackListMapper;
import com.tanhua.model.db.BlackList;
import com.tanhua.model.vo.PageResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@Slf4j
@DubboService
public class BlackListApiImpl implements BlackListApi{

    @Autowired
    private BlackListMapper blackListMapper;

    @Override
    public PageResult<BlackList> findPageBlackList(Long page, Long pagesize, Long userId) {
        //page:分页参数 queryWrapper分页查询条件
        IPage<BlackList> queryPage = new Page<>(page,pagesize);
        QueryWrapper<BlackList> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",userId);
        IPage<BlackList> iPage = blackListMapper.selectPage(queryPage, queryWrapper);
        return new PageResult<>(page,pagesize,iPage.getTotal(),iPage.getRecords());

//        IPage<BlackList> queryPage = new Page<>(page,pagesize);
//        QueryWrapper<BlackList> queryWrapper = new QueryWrapper<>();
//        queryWrapper.eq("user_id",userId);
//
//        IPage<BlackList> iPage = blackListApiMapper.selectPage(queryPage, queryWrapper);
//
//        return new PageResult<>(page,pagesize,iPage.getTotal(),iPage.getRecords());
    }
}
